/* thank to :
        Stefan Goessner/2006   http://goessner.net/ 
*/  

var dt = []; 
var spec_=" type, fillColor, lineColor, fillOpac,lineOpac, lineWidth, left, top, width, height, text, textSize, textFamily, href, points, transform, parent, ";
var specAttrSVG__=" _, fill, stroke, fill-opacity, stroke-opacity, stroke-width, x, y, width, height, text, textSize, textFamily, href, transform, parent, ";

var specSVG = { 
  "type":
  " rect, ellipse, circle, rect, line, polyline, polygon, path, text, clipPath, g, image, linearGradient, radialGradient, stop, defs, filter, feGaussianBlur, use, pattern, svg, " , //, svg,
 "fillColor":
  " fill, stop-color, " ,
 "lineColor":
  " stroke, " ,
 "fillOpac":
  " fill-opacity, opacity, stop-opacity, " ,
 "lineOpac":
  " stroke-opacity, offset, " ,
 "lineWidth":
  " stroke-width, " ,
 "left":
  " x, cx, x1, " ,
 "top":
  " y, cy, y1, " ,
 "width":
  " width, x2, rx, " ,
 "height":
  " heigth, y2, ry,  " ,  
 "text":
  " , " ,
 "textSize":
  " font-size, " ,
 "textFamily":
  " font-family, " ,
 "href":
  " href, " ,
 "points":
  " d, points, " , 
 "transform":
  " transform, " ,
 "parent":
  " , " 
};    

var SVGtype = {
 "rect":
   " fill, stroke, stroke-width, fill-opacity, stroke-opacity, x, y, width, height, transform, " ,
 "rect_":
   " fillColor, lineColor, line-width, fillOpac, lineOpac, left, top, width, height, transform, " ,
 "ellipse":
   " fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, cx, cy, rx, ry, transform, " ,
 "ellipse_":
   " fillColor, lineColor, line-width, fillOpac, lineOpac, left, top, width, height, transform, " ,
 "line":
   " fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, x1, y1, x2, y2, transform, " ,
 "line_":
   " fillColor, lineColor, line-width, fillOpac, lineOpac, left, top, width, height, transform, " ,
 "polyline":
    " fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, points, transform, " ,
 "polyline_":   
   " fillColor, lineColor, line-width, fillOpac, lineOpac, points, transform, " ,
 "path":
    " fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, d, transform, " ,
 "path_":   
   " fillColor, lineColor, line-width, fillOpac, lineOpac, points, transform, " ,
 "text":
    " fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, x, y, font-family, font-size, transform, " ,
 "text_":   
   " fillColor, lineColor, line-width, fillOpac, lineOpac, left, textFamily, textSize, transform, " ,
 "image":
   " opacity, x, y, width, height, transform, " ,
 "image_":   
   " fillOpac, left, top, width, height, transform, " ,
 "g":
   " fill-opacity, x, y, width, height, transform, " ,
 "g_":  
   " fillOpac, left, top, width, height, transform, " 
  
};
var specType_ =  "rect,ellipse,roundrect,line,polyline,path,text,clipPath,group,image,zoom"; 

var specTypeSVG_="rect,circle,ellipse,rect,line,polyline,path,text,clipPath,g,image,linearGradient,radialGradient,svg"; 

var specTypeVML_="rect,ellipse,roundrect,line,polyline,path,text,clipPath,group,image,zoom"; 
var spec=spec_.split(','); 
var specType=specType_.split(',');
var specTypeSVG=specTypeSVG_.split(',');
var specTypeVML=specTypeVML_.split(',');

////////////////////  


function info(shape)
{   
 var shInfo = {}; 
 //shInfo.id =null; 
 if(shape.tagName=='svg')
  { 
    shInfo.type ='doc'
    shInfo.left = parseFloat(shape.getAttribute('x'));
    shInfo.top = parseFloat(shape.getAttribute('y'));   
    shInfo.width = parseFloat(shape.getAttribute('width'));
    shInfo.height = parseFloat(shape.getAttribute('height'));   
    shInfo.viewBox = shape.getAttribute('viewBox');  
    //shInfo.xmlns = shape.getAttribute('xmlns'); 
    return shInfo;  
  }
  else
  {
/*   if(shape.id != "tracker")
    {
     if(shape.getAttribute('id')==null || shape.getAttribute('id')=='')
      {
       var nid='shape:' + createUUID(); 
       shape.setAttributeNS(null, 'id',  nid);
       shInfo.id=shape.getAttribute('id');
      }else{
        shInfo.id =shape.getAttribute('id');  
      }  
   }
 */   
  } 
//if(shInfo.id !=null){ 
if(shape.id != "tracker") 
{  
if(shape.getAttribute('id')==null){
   var nid='shape:' + createUUID(); 
   shape.setAttributeNS(null, 'id',  nid);
   //shInfo.id = shape.id.substr(6); 
 
 } 
 shInfo.id =shape.getAttribute('id');  
 shInfo.type = shape.tagName;
 
 
 if (shape.hasAttributeNS(null,'transform')) { 
     shInfo.transform = shape.getAttribute('transform');
  }else{
     shInfo.transform ='';
  }   
 
 if (shape.tagName =='defs') 
   { 
    //alert('dfasd'); 
    if(shape.getAttribute('id')==null || shape.getAttribute('id')=='')
     {  
      
      //var nid='shape:' + createUUID(); 
      shape.setAttributeNS(null, 'id',  'defs');
      shInfo.id=shape.getAttribute('id');
     }
     shInfo.id=shape.getAttribute('id');
   }
 if (shape.tagName == 'feGaussianBlur') 
  {
    shInfo.left = shape.getAttribute('stdDeviation');
  } 

  if(shape.tagName == "text"){   
 
   shInfo.textFamily = shape.getAttribute('font-family')
   shInfo.textSize = parseInt(shape.getAttribute('font-size'))
   shInfo.top = parseFloat(shape.getAttribute('y'))
   shInfo.left = parseFloat(shape.getAttribute('x'))
   shInfo.text = shape.textContent 
   shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))

   //shInfo.text = shape.nodparseFloatue;
   }
 var rendering=true;     
 if(shape.tagName =='image'){rendering=false;}
 if(shape.tagName =='defs'){rendering=false;}
 if(shape.tagName =='svg'){rendering=false;}
 if(shape.tagName =='stop'){rendering=false;} 
 
 if(shape.tagName =='filter'){rendering=false;}
 if(shape.tagName =='feGaussianBlur'){rendering=false;}

 
 if(rendering==true)
  {
    shInfo.fillColor = shape.getAttribute('fill');
    if((shape.getAttribute('fill')=='' || shape.getAttribute('fill')==null) && shape.parentNode.getAttribute('id')!='svg'){
    
      shInfo.fillColor = shape.parentNode.getAttribute('fill');
          var mystyle= shape.parentNode.getAttribute('style'); 
      if(mystyle!= null && mystyle.indexOf('<![CDATA[')>=0)
       {
      
       }
        else
       {
        if(mystyle!= null){
          //var estilo=shape.getAttribute('style');
           var data;  
   
          var estilo=generateJSON(mystyle);
          eval("data="+estilo);
          //var data=eval('"'+estilo+'"'); 
          //var data=estilo.evalJSON(); 
    
          (data["font-size"])?shInfo.textSize=data["font-size"]:shInfo.textSize; 
          (data["font-family"])?shInfo.textFamily=data["font-family"]:shInfo.textFamily; 
      
          (data.fill)?shInfo.fillColor=data.fill:shInfo.fillColor; 
          (data.stroke)?shInfo.lineColor=data.stroke:shInfo.lineColor;
          (data.transform)?shInfo.transform=data.transform:shInfo.transform;
         (data["fill-opacity"])?shInfo.fillOpac=data["fill-opacity"]:shInfo.fillOpac; 
          //(data["opacity"])?shInfo.fillOpac=data["opacity"]:shInfo.fillOpac;
         //(data.opacity)?shInfo.fillOpac=data.opacity:shInfo.fillOpac;  
 
        }
       
       }
    }
    shInfo.filter = shape.getAttribute('filter')  
    shInfo.lineColor = shape.getAttribute('stroke')  
    shInfo.fillOpac = parseFloat(shape.getAttribute('fill-opacity'))
    shInfo.lineOpac = parseFloat(shape.getAttribute('stroke-opacity'))
    shInfo.lineWidth = parseFloat(shape.getAttribute('stroke-width'))
    
    var mystyle= shape.getAttribute('style'); 
    
    if(mystyle!= null && mystyle.indexOf('<![CDATA[')>=0)
     {
      
     }
      else
     {
      // shInfo.style=shape.getAttribute('style');
     
    if(mystyle!= null){
      //var estilo=shape.getAttribute('style');
      var data;  
   
      var estilo=generateJSON(mystyle);
      eval("data="+estilo);
      //var data=eval('"'+estilo+'"'); 
      //var data=estilo.evalJSON(); 
    
      (data["font-size"])?shInfo.textSize=data["font-size"]:shInfo.textSize; 
      (data["font-family"])?shInfo.textFamily=data["font-family"]:shInfo.textFamily; 
      
      (data.fill)?shInfo.fillColor=data.fill:shInfo.fillColor; 
      (data.stroke)?shInfo.lineColor=data.stroke:shInfo.lineColor;
      (data.transform)?shInfo.transform=data.transform:shInfo.transform;
      (data["fill-opacity"])?shInfo.fillOpac=data["fill-opacity"]:shInfo.fillOpac; 
      //(data.color)?shInfo.lineColor=data.color:shInfo.lineColor;
      
       //shInfo.fillColor=data.fill;
      //document.getElementById("someinfo").value +=data.fill+' ';//estilo ;//data['fill']+' ';//
    }
   }
  }  
 
 
 if (shape.tagName == 'rect') 
   {
   if(shape.getAttribute('rx') || shape.getAttribute('ry')){
   shInfo.type = "roundrect";
   shInfo.rx = parseFloat(shape.getAttribute('rx'))
   shInfo.ry = parseFloat(shape.getAttribute('rx'))
   }
    shInfo.left = parseFloat(shape.getAttribute( 'x'));
    shInfo.top = parseFloat(shape.getAttribute( 'y'));
    shInfo.width = parseFloat(shape.getAttribute('width'));
    shInfo.height = parseFloat(shape.getAttribute('height'));  
   }
  else if (shape.tagName == 'ellipse' || shape.tagName == 'circle') 
   {     
    if(shape.tagName == 'circle'){
      shInfo.width = parseFloat(shape.getAttribute('r'))*2; 
      shInfo.height = parseFloat(shape.getAttribute('r'))*2; 
     }else{
      shInfo.width = parseFloat(shape.getAttribute('rx'))*2;
      shInfo.height = parseFloat(shape.getAttribute('ry'))*2;   
     }
    
    shInfo.left =    parseFloat(shape.getAttribute('cx')) - (shInfo.width/2);
    shInfo.top =  parseFloat(shape.getAttribute('cy')) - (shInfo.height/2)  ;
   }
   else if(shape.tagName == 'linearGradient') { 
    shInfo.text =shape.getAttribute('gradientUnits');//"userSpaceOnUse" 
    shInfo.left = shape.getAttribute('x1');
    shInfo.top = shape.getAttribute('y1');
    shInfo.width = shape.getAttribute('x2');
    shInfo.height = shape.getAttribute('y2');
    shInfo.href = shape.getAttribute('xlink:href');  
   } 
   else if(shape.tagName == 'radialGradient') {  
    shInfo.text =shape.getAttribute('gradientUnits');//"userSpaceOnUse" 
    shInfo.left = shape.getAttribute('cx');
    shInfo.top = shape.getAttribute('cy');
    shInfo.width = shape.getAttribute('fx');
    shInfo.height = shape.getAttribute('fy');  
    shInfo.lineWidth = shape.getAttribute('r');
    shInfo.href = shape.getAttribute('xlink:href');  
   }   
    else if(shape.tagName == 'stop') 
   {
    shInfo.fillColor = shape.getAttribute('stop-color');
    shInfo.fillOpac = shape.getAttribute('stop-opacity');
    shInfo.lineOpac = shape.getAttribute('offset');
    var mystyle= shape.getAttribute('style');
    if(mystyle!= null && mystyle.indexOf('<![CDATA[')>=0)
     {
      
     }
      else
     {
      if(mystyle!= null)
       {
        var data;  
        var estilo=generateJSON(mystyle);
        eval("data="+estilo);
        (data["stop-color"])?shInfo.fillColor=data["stop-color"]:shInfo.fillColor;
        (data["stop-opacity"])?shInfo.fillOpac=data["stop-opacity"]:shInfo.fillOpac;
        //document.getElementById("someinfo").value +=data["stop-color"]+' '; 
       } 
     }
   }
  else if (shape.tagName == 'line') 
   {
    shInfo.left = parseFloat(shape.getAttribute('x1'));
    shInfo.top = parseFloat(shape.getAttribute('y1'));
    shInfo.width = parseFloat(shape.getAttribute('x2')) -shInfo.left;
    shInfo.height = parseFloat(shape.getAttribute('y2')) -shInfo.top;
   } 
  else if (shape.tagName == 'polyline' || shape.tagName == 'polygon') 
   {
    shInfo.points = shape.getAttribute('points');
   } 
 
  else if (shape.tagName == 'g') 
   { 
    shInfo.type = "group";
    shInfo.left = parseFloat(shape.getAttribute( 'x'));
    shInfo.top = parseFloat(shape.getAttribute( 'y'));
    shInfo.width = parseFloat(shape.getAttribute('width'));
    shInfo.height = parseFloat(shape.getAttribute('height'));  
    shInfo.fillColor = shape.getAttribute('fill');
    if(shape.getAttribute('id')==null || shape.getAttribute('id')=='')
      {
       var nid='shape:' + createUUID(); 
       shape.setAttributeNS(null, 'id',  nid);
       shInfo.id=shape.getAttribute('id');
      } 

   }   
  else if (shape.tagName == 'path')
   {
    shInfo.points = shape.getAttribute('d');     
    //shInfo.transform = shape.getAttribute('transform'); 
 
    //alert(shInfo.transform);
    //document.forms[0].codebase.value=shape.getAttribute('d'); 
   
   } 
   else if (shape.tagName == 'pattern') 
   { 
    
    shInfo.left = parseFloat(shape.getAttribute( 'x'));
    shInfo.top = parseFloat(shape.getAttribute( 'y'));
    shInfo.width = parseFloat(shape.getAttribute('width'));
    shInfo.height = parseFloat(shape.getAttribute('height'));  
    shInfo.viewBox = shape.getAttribute('viewBox');
   
    if(shape.getAttribute('id')==null || shape.getAttribute('id')=='')
      {
       var nid='shape:' + createUUID(); 
       shape.setAttributeNS(null, 'id',  nid);
       shInfo.id=shape.getAttribute('id');
      } 

   }    
  else if (shape.tagName == 'image')
   {                                     
    
    shInfo.left = parseFloat(shape.getAttribute( 'x'));
    shInfo.top = parseFloat(shape.getAttribute( 'y'));
    shInfo.width = parseFloat(shape.getAttribute('width'));
    shInfo.height = parseFloat(shape.getAttribute('height'));   
    shInfo.fillOpac = parseFloat(shape.getAttribute('opacity'));   
    shInfo.href = shape.getAttribute('href');  
     
  }                                               
  else if (shape.tagName == 'use')
   {                                     
    
    shInfo.href = shape.getAttribute('xlink:href');  
     
  }             
  if(shape.parentNode.tagName != 'svg'){
    //shInfo.width = parseFloat(shape.getAttribute('width'));
    //shInfo.height = parseFloat(shape.getAttribute('height'));   
    //shInfo.viewBox = shape.getAttribute('viewBox');   
    shInfo.parent=shape.parentNode.getAttribute('id');

  }
    return shInfo;  
  }else{
   //do nothing if its the tracker
   }
  
   	
   	
};

/////////////////////


function shape(shape){
return info(shape)
} 



function canvas(ct){

//alert(ct)
//var dt = []; //array containing shapes
for(var i = 0; i < ct; i++){ //loop through shapes
//dt.push(shape(richdraw,richdraw.renderer.svgRoot.childNodes[i])); //MAKE CROSS-Platfrom!!!
  dt.push(shape(childNodes[i])); //MAKE CROSS-Platfrom!!!
       
}  
//var dump=dt.join(' ');
//alert(dump);
return dt;
}





function xml2OPF(xml, tab) {
   var X = {
      toObj: function(xml) { 
         
       /*  if(specSVG.type.indexOf(xml.tagName+',')>=0){
          document.getElementById("divdump").innerHTML +="SPEC:"+xml.tagName+'<br>';
          }else{document.getElementById("divdump").innerHTML +=xml.tagName+' NO spec <br>';
          }
       */  
         var o = {}; 
         
              if(specSVG.type.indexOf(' '+xml.tagName+',')>=0){
                  //dt.push(drawSpace.renderer.info(xml));
                  //dt.push(info(xml));
                  dt.push(instance[1].renderer.info(xml));                                        
               }
              
        
         if (xml.nodeType==1) {   // element node ..
            if (xml.attributes.length){   // element with attributes  ..
  
               for (var i=0; i<xml.attributes.length; i++){  
                   o[""+xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue||"").toString();
               } 
             }    
            if (xml.firstChild) { // element has child nodes ..
               var textChild=0, cdataChild=0, hasElementChild=false;
               for (var n=xml.firstChild; n; n=n.nextSibling) {
                  if (n.nodeType==1) hasElementChild = true;
                  else if (n.nodeType==3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) textChild++; // non-whitespace text
                  else if (n.nodeType==4) cdataChild++; // cdata section node
               }
               if (hasElementChild) {
                  if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node ..
                     X.removeWhite(xml);
                     for (var n=xml.firstChild; n; n=n.nextSibling) {
                        if (n.nodeType == 3)  // text node
                           o["#text"] = X.escape(n.nodeValue);
                        else if (n.nodeType == 4)  // cdata node
                           o["#cdata"] = X.escape(n.nodeValue);
                        else if (o[n.nodeName]) {  // multiple occurence of element ..
                           if (o[n.nodeName] instanceof Array)
                              o[n.nodeName][o[n.nodeName].length] = X.toObj(n);
                           else
                              o[n.nodeName] = [o[n.nodeName], X.toObj(n)];
                        }
                        else  // first occurence of element..
                           o[n.nodeName] = X.toObj(n);
                     }
                  }
                  else { // mixed content
                     if (!xml.attributes.length)
                        o = X.escape(X.innerXml(xml));
                     else
                        o["#text"] = X.escape(X.innerXml(xml));
                  }
               }
               else if (textChild) { // pure text
                  if (!xml.attributes.length)
                     o = X.escape(X.innerXml(xml));
                  else
                     o["#text"] = X.escape(X.innerXml(xml));
               }
               else if (cdataChild) { // cdata
                  if (cdataChild > 1)
                     o = X.escape(X.innerXml(xml));
                  else
                     for (var n=xml.firstChild; n; n=n.nextSibling)
                        o["#cdata"] = X.escape(n.nodeValue);
               }
            }
            if (!xml.attributes.length && !xml.firstChild) o = null;
         }
         else if (xml.nodeType==9) { // document.node

            o = X.toObj(xml.documentElement);
         }
         else
            alert("unhandled node type: " + xml.nodeType);
         return o;
      },
      toJson: function(o, name, ind) {  
      
         var json = name ? ("\""+name+"\"") : "";
          //if(specSVG.type.indexOf(xml.tagName+',')>=0){
          //document.getElementById("divdump").innerHTML +="SPEC:"+xml.tagName+'<br>';
          //document.getElementById("divdump").innerHTML +=name+': '+o[i].toString()+'<br>';
          //}else{document.getElementById("divdump").innerHTML +=xml.tagName+' NO spec <br>';
          //}
          
         //var jsonrdf = name ? ("\""+name+"\"") : ""; 
         
         
         if (o instanceof Array) {
            for (var i=0,n=o.length; i<n; i++){
               o[i] = X.toJson(o[i], "", ind+"\t");
            }   
            json += (name?":[":"[") + (o.length > 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]";      

         } 
         else if (o == null)
            json += (name&&":") + "null";
         else if (typeof(o) == "object") {
            var arr = [];
            for (var m in o)
               arr[arr.length] = X.toJson(o[m], m, ind+"\t");
            json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}";
         }
         else if (typeof(o) == "string")
            json += (name&&":") + "\"" + o.toString() + "\"";
         else
            json += (name&&":") + o.toString();
         return json;
      },
      innerXml: function(node) {
         var s = ""
         if ("innerHTML" in node)
            s = node.innerHTML;
         else {
            var asXml = function(n) {
               var s = "";
               if (n.nodeType == 1) {
                  s += "<" + n.nodeName;
                  for (var i=0; i<n.attributes.length;i++)
                     s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue||"").toString() + "\"";
                  if (n.firstChild) {
                     s += ">";
                     for (var c=n.firstChild; c; c=c.nextSibling)
                        s += asXml(c);
                     s += "</"+n.nodeName+">";
                  }
                  else
                     s += "/>";
               }
               else if (n.nodeType == 3)
                  s += n.nodeValue;
               else if (n.nodeType == 4)
                  s += "<![CDATA[" + n.nodeValue + "]]>";
               return s;
            };
            for (var c=node.firstChild; c; c=c.nextSibling)
               s += asXml(c);
         }
         return s;
      },
      escape: function(txt) {
         return txt.replace(/[\\]/g, "\\\\")
                   .replace(/[\"]/g, '\\"')
                   .replace(/[\n]/g, '\\n')
                   .replace(/[\r]/g, '\\r');
      },
      removeWhite: function(e) {
         e.normalize();
         
         for (var n = e.firstChild; n; ) {
            if (n.nodeType == 3) {  // text node
               if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node
                  var nxt = n.nextSibling;
                  e.removeChild(n);
                  n = nxt;
               }
               else
                  n = n.nextSibling;
            }
            else if (n.nodeType == 1) {  // element node
               X.removeWhite(n);
               n = n.nextSibling;
            }
            else                      // any other node
               n = n.nextSibling;
         }
         return e;
      }
   };
   if (xml.nodeType == 9) // document node
      xml = xml.documentElement;
   var json = X.toJson(X.toObj(X.removeWhite(xml)), xml.nodeName, "\t");
   return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}";
}


String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') }

function generateJSON(cssEnv)
{    
 //string=string.replace(/;/g,'",') ;
 //string=string.replace(/:/g,':"') ; 
 //style="fill:#7e0000;fill-opacity:1" 
 
 var css=cssEnv.split(';')

  var strJSON = '{';
  ch = ',';
  for (i = 0 ; i < css.length; i++)
  { 
   var data=css[i].split(':'); 
   if(data[0]!=''){ 
     //if(i == (css.length-2)){   ch = ''; }   
     strJSON += "'"+data[0].trim()+"':'"+data[1].trim()+"'"+",";
   } 
      
   
  } 
  var num=  strJSON.length;
  strJSON=strJSON.substr(0, num-1);

  strJSON += '}';

  return strJSON;
}   

var myHttpRequest = false;

if(window.XMLHttpRequest)
     myHttpRequest = new XMLHttpRequest();
else if(window.ActiveXObject)
     myHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");

function loadContent01(source, content, numFile)
{
     if(myHttpRequest)
     {
          var data = document.getElementById(content);

          myHttpRequest.open("GET",source);

          myHttpRequest.onreadystatechange = function()
          {
               if(myHttpRequest.readyState==4)
                {
                   var mycharge;
                   var info = myHttpRequest.responseText;
                   
                   eval("mycharge="+info);
                   //frames=mycharge;   
                   frames[numFile]=mycharge;  
                   initialFile=source;
                   //data.innerHTML = cad[1][0].id;
                   //data.innerHTML +='<br>'+ info;
                }    
          }

          myHttpRequest.send(null);
     }
}

///////////////


/////////////
function loadSVG(source, content)
{
     if(myHttpRequest)
     {
          //var data = document.getElementById(content);
          alert(source);
          myHttpRequest.open("GET",source);

          myHttpRequest.onreadystatechange = function()
          {
               if(myHttpRequest.readyState==4)
                {
                   
                   //var svg = myHttpRequest.responseText;
                   document.getElementById("xml").value= myHttpRequest.responseText;
                  
                }    
          }

          myHttpRequest.send(null);
     }
}  

function doXSL(xsl_filename, xml_text)
{
  var result = "";
  if (window.ActiveXObject)
  {
    var xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;
    xml.loadXML(xml_text);
    var xsl = new ActiveXObject("Microsoft.XMLDOM");
    xsl.async = false;
    xsl.load(xsl_filename);
    result = xml.transformNode(xsl);
  }
  else
  {
    var xml = (new DOMParser()).parseFromString(xml_text, "text/xml");
    var xsl = document.implementation.createDocument("", "", null);
    xsl.async = false;
    xsl.onload = function()
    {
      var processor = new XSLTProcessor();
      processor.importStylesheet(xsl);
      result = (new XMLSerializer()).serializeToString(processor.transformToDocument(xml));
    }
    xsl.load(xsl_filename);
  }  
  return result;
} 

var xml=[

]; 

function parseXml(xml) {
   var dom = null;
   if (window.DOMParser) {
      try { 
         dom = (new DOMParser()).parseFromString(xml, "text/xml"); 
         //image/svg+xml
      } 
      catch (e) { dom = null; }
   }
   else if (window.ActiveXObject) {
      try {
         dom = new ActiveXObject('Microsoft.XMLDOM');
         dom.async = false;
         if (!dom.loadXML(xml)) // parse error ..
            window.alert(dom.parseError.reason + dom.parseError.srcText);
      } 
      catch (e) { dom = null; }
   }
   else
      alert("oops");
   return dom;
}   


function xaml2svg(){
        var xml_text = document.getElementById("xaml").value;
       var xml_result= xml2OPF(parseXml(xml_text), "  ");
        document.getElementById("xml").value = xml_result;//.replace(/<svg/, "<svg xmlns=\"http://www.w3.org/2000/svg\"");
}        

/*
    var cssjson = {
        "selector-1":{
            "property-1":"value-1",
            "property-n":"value-n"
        }
    }

    var styleStr = "";
    for(var i in cssjson){
        styleStr += i + " {\n"
        for(var j in cssjson[i]){
            styleStr += "\t" + j + ":" + cssjson[i][j] + ";\n"     
        }
        styleStr += "}\n"  
    }
*/    